#include <iostream>
#include <fstream>
#include "vector.h"

//using namespace cv;
using namespace std;

void testVector(){
	Vector<int> vec1, vec2(5);

	vec1.SetRowVector(5);
	vec1.Zero();
	//vec2.SetRowVector(5);
	vec2.Zero();
	cout << vec1.rows() << " " << vec1.cols() << " " << vec1.size() << endl;
	cout << "1: " << vec1 << " " << vec2 << endl;

	vec1 = vec1 + 2;
	vec2 = vec2 - 3;
	cout << "2: " << vec1 << " " << vec2 << endl;

	vec1 = vec1 * 2;
	vec2 = vec2 / 3;
	cout << "3: " << vec1 << " " << vec2 << endl;

	Vector<int> vec3(vec2);
	cout << vec1 + vec3 << endl;
	cout << vec1 - vec3 << endl;
	vec3 = vec1 + vec2;
	cout << "4: " << vec1 << " " << vec2 << " " << vec3 << endl;

	cout << vec1.rows() << " " << vec1.cols() << " " << vec1.size() << endl;
	//vec1.setData(Mat(Size(1, 5), CV_16U, Scalar(3)));
	cout << vec1.data << endl;

	vec1.ExpandTo(4);
	vec2.ExpandTo(4);
	cout << vec1.Norm(1) << " " << vec1.Norm(2) << endl;
	cout << "5: " << vec1 << " " << vec2 << endl;

	cout << vec1.RowVector() << " " << vec2.RowVector()  << " " << vec3.RowVector() << endl;
	cout << vec1.Data(1) << " " << vec1.Data(2) << endl;
	cout << vec1.Projection(vec2) << " " << vec1.DotProduct(vec2) << endl;
	cout << "6: " << vec1 << " " << vec2 << endl;

	vec3.ExpandTo(10);
	vec3.CopyContent(vec1, 3);
	cout << "7: " << vec1.size() << " " << vec2.size() << " " << vec3.size() << endl;
	cout << "7: " << vec1 << " " << vec2 << " " << vec3 << endl;
	cout << vec1.Sum() << " " << vec2.Sum() << endl;
	cout << vec3.Data(0) << vec3.Data(1) << vec3.Data(2) << vec3.Data(3) << vec3.Data(4) << vec3.Data(5) << endl;
	cout << vec3(0) << vec3(1) << vec3(2) << vec3(3) << vec3(4) << vec3(5) << endl;

	cout << vec3.Valid(0, 9) << " " << vec3.Valid(9) << endl;

	ofstream fout;
	fout.open("D:/Works/Research/DDMCMC/svn/testing/vector/data.txt", ios::out);
	vec1 >> fout;
	fout.close();

	Vector<int> vec4;
	ifstream fin;
	fin.open("D:/Works/Research/DDMCMC/svn/testing/vector/data.txt", ios::in);
	vec4 << fin;
	fin.close();

	cout << "Read back vec1 from file: " << vec4 << endl;
	
	//vec4 = vec4.T();
	cout << vec4 << " " << vec4.Mean() << " " << vec4.RowVector() << " " << vec4.size() << endl;
	//cout << vec1 * vec4 << endl;
	//cout << vec2 << " " << vec2.T().Dist(vec4) << endl;
	Vector<int> vec5;
	vec5.SetColVector(5);
	vec5.InitValue(3);
	cout << vec1*vec5 << endl;
	Matrix<int> mat;
	mat.SetDimension(5, 3);
	mat.InitValue(2);
	cout << vec1*mat << " " << (vec1*mat).Sum() << endl;

	return;
}

void testVector1(){
	Vector<double> vec;
	vec.SetRowVector(10);
	vec.InitValue(15);
	cout << vec << endl;
}

int main(){
	testVector();

	system("pause");
	return 0;
}
